﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using Interface_Tier;
using Transfer_Object_Tier;

namespace eSolution_HRMSS.Winforms.QuaTrinhLamViec
{
    public partial class FR_ThayDoiChucVu : DevExpress.XtraEditors.XtraForm
    {
        IHRM_PROCESS_POSITIONData _IHRM_PROCESS_POSITIONData;
        ICommonCode _icommon;
        eSolution_HRMSS.HRMSS_Ultil util = new HRMSS_Ultil();
        Guid currentId;
        Guid new_id;
        bool isUpdate = false;
         public FR_ThayDoiChucVu(bool _isUpdate)
        {
            InitializeComponent();
            isUpdate = _isUpdate;
        }

         public FR_ThayDoiChucVu(bool _isUpdate, Guid _currentId)
        {
            InitializeComponent();
            isUpdate = _isUpdate;
            currentId = _currentId;
        }

        private void FR_ThayDoiChucVu_Load(object sender, EventArgs e)
        {
            _IHRM_PROCESS_POSITIONData = (IHRM_PROCESS_POSITIONData)Activator.GetObject(typeof(IHRM_PROCESS_POSITIONData), util.ChuoiPROCESS_POSITIONData);
            _icommon = (ICommonCode)Activator.GetObject(typeof(ICommonCode), util.Chuoicommon);     
        }
        private HRM_PROCESS_POSITION lay_thong_tin()
        {
            string chinhanhcu = lu_chinhanhcu.EditValue.ToString();
            string phongbancu = lu_phongbancu.EditValue.ToString();
            string tocu = lu_tocu.EditValue.ToString();
            string chinhanhmoi = lu_chinhanhmoi.EditValue.ToString();
            string phongbanmoi = lu_phongbanmoi.EditValue.ToString();
            string tomoi = lu_tomoi.EditValue.ToString();
            string chucvumoi = lu_chucvumoi.EditValue.ToString();
            string chucvucu = txtchucvucu.Text;
            string lydothaydoi = txtlydothaydoi.Text;
            string soquyetdinh = txtsoquyetdinh.Text;
            string nguoibanhanh = txtnguoibanhanh.Text;

            DateTime ngaythaydoi = dtngaythaydoi.DateTime;
            HRM_PROCESS_POSITION position = new HRM_PROCESS_POSITION();
            position.OldBranch = chinhanhcu;
            position.OldDepartment = phongbancu;
            position.OldGroup = tocu;
            position.NewBranch = chinhanhmoi;
            position.NewDepartment = phongbanmoi;
            position.NewGroup = tomoi;
            position.NewPosition = chucvumoi;
            position.OldPosition = chucvucu;
            position.Reason = lydothaydoi;
            position.DecideNumber = soquyetdinh;
            position.Person = nguoibanhanh;
            position.Date = ngaythaydoi;
            return position;
        }
        private void load_info()
        {
            DataTable dt = _IHRM_PROCESS_POSITIONData.HRM_PROCESS_POSITION_Get(currentId).Tables[0];
            foreach (DataRow dr in dt.Rows)
            {
                lu_chinhanhcu.EditValue = dr["OldBranch"].ToString();
                lu_phongbancu.EditValue = dr["OldDepartment"].ToString();
                lu_tocu.EditValue = dr["OldGroup"].ToString();
                lu_chinhanhmoi.EditValue = dr["NewBranch"].ToString();
                lu_phongbanmoi.EditValue = dr["NewDepartment"].ToString();
                lu_tomoi.EditValue = dr["NewGroup"].ToString();
                lu_chucvumoi.EditValue = dr["NewPosition"].ToString();
                txtchucvucu.Text = dr["OldPosition"].ToString();
                txtlydothaydoi.Text = dr["Reason"].ToString();
                txtsoquyetdinh.Text = dr["DecideNumber"].ToString();
                txtnguoibanhanh.Text = dr["Person"].ToString();
                dtngaythaydoi.DateTime = DateTime.Parse(dr["Date"].ToString());
            }
        }
    }
}